<?php
include '/var/www/html/wx/wechat/lanewechat.php';
//include '/var/www/html/wx/wechat/core/db.lib.php';
$sql = "SELECT appid FROM pft_wx WHERE fid=? LIMIT 1";
$stmt = \LaneWeChat\Core\Db::Connect()->prepare($sql);
$stmt->execute(array($_SESSION['memberID']));
$appid = $stmt->fetchColumn(0);

$search = array('{%APPID%}', '{%REDIRECT_URI%}');
$uri    = 'http://wx.12301.cc/html/jump.php?jid=Wl';
$replace = array('wxd72be21f7455640d',$uri);
$link = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid={%APPID%}&redirect_uri={%REDIRECT_URI%}&response_type=code&scope=snsapi_base&state#wechat_redirect';
$link = str_replace($search, $replace, $link);
//echo $link;
//$link = 'http://www.qq.com';
$short_url = \LaneWeChat\Core\Popularize::long2short($link);
//$redirect_uri = '获取CODE时，发送请求和参数给微信服务器，微信服务器会处理后将跳转到本参数指定的URL页面';
//$code = \LaneWeChat\Core\WeChatOAuth::getCode($short_url, $state=1, $scope='snsapi_base');

print_r($short_url);

//curl -d "{\"action\":\"long2short\",\"long_url\":\"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd72be21f7455640d&redirect_uri=http%3A%2F%2Fwx.12301.cc%2Fhtml%2Fjump.php%3Fjid%3D15&response_type=code&scope=snsapi_base&state#wechat_redirect\"}" "https://api.weixin.qq.com/cgi-bin/shorturl?access_token=_Z6pKZQnxWtWKcOahz4LDtS-YRiIsvYIpelxvnBNetapaMUUnQuGzq3LwxLbfqhd7kI_9vkFylSNbPa4RopEJUOq8y_D4NjcX25ItCiWz5k"